package com.sfzlot.dev.netty.bean.command;

import com.sfzlot.dev.netty.bean.inf.Command;

/**
 * Created by ASUS on 2017/5/27.
 * 智慧家庭-智慧家居-智能开关命令标识
 */
public enum  PowerSwitchCommand implements Command {
    DEVICE_LOGIN(0x01),      	// 设备登入
    DEVICE_STATUS(0x02),    	// 设备状态上报
    DEVICE_LOGOUT(0x03),       	// 设备登出
    DEVICE_SERVER(0x04),		// 更改服务器
    DEVICE_SETTING(0x05),		// 更改WIFI账号和密码
    DEVICE_INFO(0x06),			// 获取终端信息
	DEVICE_START(0x07),			// 开关-通电
	DEVICE_STOP(0x08),			// 开关-断电
	DEVICE_RESET(0x09),			// 重置设备
	DEVICE_SWITCH(0x0a);		// 物理开关是否有效
	
    private int code;
    
    PowerSwitchCommand(int code){
        this.code = code;
    }

    @Override
    public int getCode() {
		return code;
	}

	/**
     * 根据码获取命令标识对象
     * @param code
     * @return
     */
    public static PowerSwitchCommand getCommand(int code){
        for (PowerSwitchCommand commandIdentifier :
                PowerSwitchCommand.values()) {
            if (commandIdentifier.code == code) {
                return commandIdentifier;
            }
        }
        throw new IllegalArgumentException();
    }
    
    /**
     * 根据码获取命令对应的备注
     * 
     */
    @Override
    public String getCommandComment(){
    	switch (this) {
			case DEVICE_LOGIN:return "设备登入";
			case DEVICE_STATUS:return "设备状态上报";
			case DEVICE_LOGOUT:return "设备登出";
			case DEVICE_SERVER:return "更改服务器";
			case DEVICE_SETTING:return "更改WIFI账号和密码";
			case DEVICE_INFO:return "获取终端信息";
			case DEVICE_START:return "通电";
			case DEVICE_STOP:return "断开";
			case DEVICE_RESET:return "重置";
		default:
			break;
    	}
		return null;
    }
}
